import api from "../utils/request.js"
const adminApi={
    getAllData: (params) => {
        return api.post('/user/getAllData', params)
            .then(response => response.data)
            .catch(error => {
                console.error("分页查询失败:", error)
                return { code: 500, message: '请求失败' }
            })
    },
    changeStatus: (userData) => {
        return api.post('/user/changeStatus', userData)
            .then(response => response.data)
            .catch(error => {
                console.error("状态修改失败:", error)
                return { code: 500, message: '操作失败' }
            })
    },
    updateById: (userData) => {
        return api.post('/user/updateById', userData)
            .then(response => response.data)
            .catch(error => {
                console.error("更新失败:", error)
                return { code: 500, message: '操作失败' }
            })
    },
    getUserRoleList: (params) => {
        return api.post('/user/getUserRoleList', params)
            .then(response => response.data)
            .catch(error => {
                console.error("查询失败:", error)
                return { code: 500, message: '请求失败' }
            })
    },
    updateUserRole: (data) => {
        return api.post('/user/updateUserRole', data)
            .then(response => response.data)
            .catch(error => {
                console.error("角色修改失败:", error)
                return { code: 500, message: '操作失败' }
            })
    },
    getAnnouncementList: (params) => {
        return api.post('/announcement/listAnnouncements', params)
            .then(response => response.data)
            .catch(error => {
                console.error("获取公告列表失败:", error);
                return { code: 500, message: '请求失败' };
            });
    },
    createAnnouncement: (announcementData) => {
        return api.post('/announcement/saveAnnouncement', announcementData)
            .then(response => response.data)
            .catch(error => {
                console.error("创建公告失败:", error);
                return { code: 500, message: '操作失败' };
            });
    },
    updateAnnouncement: (announcementData) => {
        return api.post('/announcement/updateAnnouncement', announcementData)
            .then(response => response.data)
            .catch(error => {
                console.error("更新公告失败:", error);
                return { code: 500, message: '操作失败' };
            });
    },
    deleteAnnouncement: (id) => {
        return api.post('/announcement/deleteAnnouncement', { id })
            .then(response => response.data)
            .catch(error => {
                console.error("删除公告失败:", error);
                return { code: 500, message: '操作失败' };
            });
    },
    getAnnouncementDetail: (id) => {
        return api.post('/announcement/getAnnouncementById', { id })
            .then(response => response.data)
            .catch(error => {
                console.error("获取公告详情失败:", error);
                return { code: 500, message: '请求失败' };
            });
    },
    addCarousel: (carouselData) => {
        return api.post('/carousel/saveCarousel', carouselData)
            .then(response => response.data)
            .catch(error => {
                console.error("添加轮播图失败:", error)
                return { code: 500, message: '操作失败' }
            })
    },
    updateCarousel: (carouselData) => {
        return api.post('/carousel/updateCarousel', carouselData)
            .then(response => response.data)
            .catch(error => {
                console.error("更新轮播图失败:", error)
                return { code: 500, message: '操作失败' }
            })
    },
    deleteCarousel: (carouselData) => {
        return api.post('/carousel/deleteCarousel', carouselData)
            .then(response => response.data)
            .catch(error => {
                console.error("删除轮播图失败:", error)
                return { code: 500, message: '操作失败' }
            })
    },
    getCarouselDetail: (carouselData) => {
        return api.post('/carousel/getCarouselById', carouselData)
            .then(response => response.data)
            .catch(error => {
                console.error("获取轮播图详情失败:", error)
                return { code: 500, message: '请求失败' }
            })
    },
    getAllCarousels: (queryDTO) => {
        return api.post('/carousel/listCarousels', queryDTO)
            .then(response => response.data)
            .catch(error => {
                console.error("获取轮播图列表失败:", error)
                return { code: 500, message: '请求失败' }
            })
    }
}
export default  adminApi
